package com.jltx.xq.relaxnewspro.fragment;

import android.support.v7.widget.RecyclerView;

import com.jltx.xq.relaxnewspro.R;
import com.jltx.xq.relaxnewspro.adapter.ReadingAdapter;
import com.jltx.xq.relaxnewspro.database.cache.ReadingCache;

/**
 * Created by bo on 2017/5/1.
 */

public class ReadingFragment extends BaseListFragment {
    private int pos;
    private String mCategory;
    private String [] mUrls;

    @Override
    protected RecyclerView.Adapter bindAdapter() {
        return new ReadingAdapter(getContext(),cache);
    }

    @Override
    protected void onCreateCache() {
        cache = new ReadingCache(handler,mCategory,mUrls);
    }

    @Override
    protected void loadFromCache() {
        cache.loadFromCache();
    }

    @Override
    protected void loadFromNet() {
        cache.load();
    }

    @Override
    protected boolean hasData() {
        return cache.hasData();
    }

    @Override
    protected void getArgs() {
        pos = getArguments().getInt(getString(R.string.id_pos));
        mCategory = getArguments().getString(getString(R.string.id_category));
//        final String[] tags = ReadingApi.getTags(ReadingApi.getApiTag(pos));
//        mUrls = new String[tags.length];
//        for(int i = 0; i < tags.length;i++ ){
//            mUrls[i] = ReadingApi.searchByTag + tags[i];
//        }
    }
}
